package sg.edu.nus.iss.vmcs.ui.factory.awt;

import sg.edu.nus.iss.vmcs.system.SimulatorControlPanel;
import sg.edu.nus.iss.vmcs.ui.component.BorderLayout;
import sg.edu.nus.iss.vmcs.ui.component.Button;
import sg.edu.nus.iss.vmcs.ui.component.Checkbox;
import sg.edu.nus.iss.vmcs.ui.component.Dialog;
import sg.edu.nus.iss.vmcs.ui.component.Font;
import sg.edu.nus.iss.vmcs.ui.component.GridLayout;
import sg.edu.nus.iss.vmcs.ui.component.Label;
import sg.edu.nus.iss.vmcs.ui.component.Panel;
import sg.edu.nus.iss.vmcs.ui.component.TextField;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtBorderLayout;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtButton;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtCheckbox;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtDialog;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtFont;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtGridLayout;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtLabel;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtPanel;
import sg.edu.nus.iss.vmcs.ui.component.awt.AwtTextField;
import sg.edu.nus.iss.vmcs.ui.factory.UIComponentAbstractFactory;

public class AwtUIComponentAbstractFactory extends UIComponentAbstractFactory {
	
	private static AwtUIComponentAbstractFactory instance = null;
	
	/** 
	 * Constructor with protected modifier makes this class a singleton
	 * 
	 */
	protected AwtUIComponentAbstractFactory() {
		
	}
	
	/**
	 * This method returns the single instance created by lazy initialization
	 * 
	 * @return AwtUIComponentAbstractFactory
	 */
	public static AwtUIComponentAbstractFactory getInstance() {
		if(instance == null) {
			instance = new AwtUIComponentAbstractFactory();
		}
		return instance;
	}

	@Override
	public Label createLabel() {
		return new AwtLabel();
	}
	
	@Override
	public Label createLabel(String text) {
		return new AwtLabel(text);
	}

	@Override
	public Label createLabel(String text, int alignment) {
		return new AwtLabel(text, alignment);
	}
	
	@Override
	public Font createFont(String name, int style, int size) {
		return new AwtFont(name, style, size);
	}

	@Override
	public TextField createTextField() {
		return new AwtTextField();
	}
	
	@Override
	public TextField createTextField(String text) {
		return new AwtTextField(text);
	}

	@Override
	public TextField createTextField(int columns) {
		return new AwtTextField(columns);
	}

	@Override
	public TextField createTextField(String text, int columns) {
		return new AwtTextField(text, columns);
	}

	@Override
	public Button createButton() {
		return new AwtButton();
	}
	
	@Override
	public Button createButton(String label) {
		return new AwtButton(label);
	}

	@Override
	public Checkbox createCheckbox() {
		return new AwtCheckbox();
	}

	@Override
	public Checkbox createCheckbox(String label) {
		return new AwtCheckbox(label);
	}

	@Override
	public Checkbox createCheckbox(String label, boolean state) {
		return new AwtCheckbox(label, state);
	}

	@Override
	public Dialog createDialog(SimulatorControlPanel owner, String title, boolean modal) {
		return new AwtDialog(owner, title, modal);
	}

	@Override
	public Panel createPanel() {
		return new AwtPanel();
	}

	@Override
	public BorderLayout createBorderLayout() {
		return new AwtBorderLayout();
	}

	@Override
	public GridLayout createGridLayout() {
		return new AwtGridLayout();
	}

	@Override
	public GridLayout createGridLayout(int arg0, int arg1) {
		return new AwtGridLayout(arg0, arg1);
	}
}
